package com.zhou.myHttpClient;

import sun.misc.BASE64Decoder;

import java.io.FileOutputStream;
import java.io.OutputStream;

/**
 * @ClassName: 获取文件流，转为文件存储到指定位置
 * @Description:
 * @Author: admin
 * @Date: 2021/12/23 20:29
 */
public class FileUtil {

    public int TurnFile(String fileStream,String path) {
        int flag=0;
        try {
            byte[] byteStream=new BASE64Decoder().decodeBuffer(fileStream);
            System.out.println("base64解码:="+byteStream);
            OutputStream out=new FileOutputStream(path);
            out.write(byteStream, 0, byteStream.length);
            out.flush();
            out.close();
            flag=1;
        } catch (Exception e) {
// TODO: handle exception
            e.printStackTrace();
        }
        return flag;
    }
}
